package com.mapbased.wfw;

import java.io.*;
import javax.servlet.http.*;

/**
 * <p>Title: </p>
 *
 * <p>Description: Render a email body or generate static content</p>
 * do not write to the default servlet output ,write to a given writer
 *
 * <p>Copyright: Copyright (c) 2004</p>
 *
 * <p>Company: mapbased.com</p>
 *
 * @author chy_hs(Baily)
 * @version 1.0
 */
public class LocalRenderContext
    extends RenderContext
{
    private Writer writer;
    public LocalRenderContext(RenderContext parent)
    {
        super(parent.getRequest(),parent.getResponse(),parent.global);
        writer=new StringWriter();
        this.locale=parent.locale;
        this.setPageHandler(parent.getPageHandler());
        /**
         * don't create a requestmap again for performance
         */
        requestMap=parent.requestMap;
        this.remoteAddr=parent.remoteAddr;

    }

    final protected void buildRequestMap()
    {}

    public LocalRenderContext(RenderContext parent,Writer w)
    {

        this(parent);
        this.writer=w;

    }

    public HttpServletResponse getResponse()
    {
        throw new java.lang.IllegalAccessError(
            "Cannot get Response Object from LocalRenderContext");
    }

    public Writer getOutputWriter()
        throws IOException
    {
        return this.writer;
    }

    /**
     * Returns a string representation of the object.
     *
     * @return a string representation of the object.
     * @todo Implement this java.lang.Object method
     */
    public String toString()
    {
        return this.getContent();
    }
    public String getContent()
    {
        return this.writer.toString();
    }


}
